﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xna.Framework;
namespace WarriorRush.GameDynamics
{
    public class ArenaSquare
    {
        /// <summary>
        /// Sets the square character and sets the square property of the character
        /// </summary>
        public CharacterClass Character
        {
            set
            {
                character = value;
                if (value != null && value.Square != this)
                {
                    value.Square = this;
                }
                
            }
            get { return character; }
        }
        public int Column;
        public int Row;
        private CharacterClass character;
        public Rectangle Box;
        public Vector2 Position { get {
            position.X= Box.X;
            position.Y = Box.Y;
            return position;
        
        } }

        public ArenaSquare Behind;
        public ArenaSquare Above;
        public ArenaSquare Below;
        private Vector2 position;
        public bool HasWarrior { get { return character != null; } }
        public ArenaSquare(int row, int col)
        {
            position = new Vector2();
            
            Row = row;
            Column = col;
            GetSquarePosition();
        }

        private void GetSquarePosition()
        {
            var sideValue = Row > 1 ? 750 : 50;
            var rowHeight = 140;
            var rowWidth = 128;
            this.Box = new Rectangle((Row * rowWidth) + sideValue, Column * rowHeight, rowWidth, rowHeight);

        }

        public void MoveCharacterToSquare(ArenaSquare destinationSquare)
        {
            destinationSquare.Character = Character;
            Character = null;
   
        }

        
        public void SwapCharacters(ArenaSquare swapSquare)
        {


        }
    }
}
